package cn.woblog.android.common.skin.demo;

import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.woblog.android.common.skin.ThemeInfo;
import cn.woblog.android.common.skin.core.ThemeManager;
import cn.woblog.android.common.skin.demo.ThemeListAdapter.OnThemeChangedListener;

public class SettingActivity extends BaseActivity implements OnThemeChangedListener {

	private TextView tv_current_theme;
	private ListView lv_skins_list;
	private ThemeListAdapter themeListAdapter;
	private LinearLayout rl_root;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);
	}

	@Override
	protected void initViews() {
		rl_root = (LinearLayout) findViewById(R.id.rl_root);
		tv_current_theme = (TextView) findViewById(R.id.tv_current_theme);
		lv_skins_list = (ListView) findViewById(R.id.lv_skins_list);
		super.initViews();
	}

	@Override
	protected void initDatas() {
		super.initDatas();
	}

	@Override
	protected void notifyAdapter() {
		themeListAdapter = new ThemeListAdapter(this, ThemeManager.getThemes(), this);
		lv_skins_list.setAdapter(themeListAdapter);
		super.notifyAdapter();
	}

	@Override
	protected void initStyle() {
		tv_current_theme.setTextColor(ThemeManager.getColor(R.color.main_btn1));
		rl_root.setBackgroundDrawable(ThemeManager.getDrawable(R.drawable.main_backgroun));
		super.initStyle();
	}

	@Override
	public void onThemeChanged(ThemeInfo info) {
		ThemeManager.changeTheme(info);
		refreshUI();
	}

}
